<?php

namespace addons\mental\model;

use think\Model;
use traits\model\SoftDelete;

class Question extends Model
{

    use SoftDelete;    
    // 表名
    protected $name = 'mental_question';    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'type_text'
    ];
        
    public function getTypeList()
    {
        return ['skip' => __('Type skip'), 'mark' => __('Type mark')];
    }

    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getQuestionAttr($value)
    {
        return json_decode($value,true);
    }

    // public function getImageAttr($value){
    //     if(!$value){
    //         return $value;
    //     }
    //     return cdnurl($value,true);
    // }

}
